<%title='上级无线列表'%>
<%+fqrouter/header%>
<style type="text/css">
    .ssid {
        width: 12em;
    }

    .signal-strength {
        width: 2em;
    }
</style>
<h2>扫描到的无线</h2>
<% if not no_upstream_available then %>
<table class="table">
    <thead>
    <tr>
        <th class="ssid">名称</th>
        <th class="signal-strength">信号强度</th>
        <th></th>
    </tr>
    </thead>
    <tbody>
    <% for ssid, wifi in pairs(upstream_list) do %>
    <tr>
        <td>
            <% if wifi.password then %>
            <form method="GET" action="<%=configure_url%>">
                <input type="hidden" name="ssid" value="<%=ssid%>">
                <input type="hidden" name="bssid" value="<%=wifi.bssid%>">
                <input type="hidden" name="encryption" value="<%=wifi.encryption%>">
                <input type="hidden" name="password" value="<%=wifi.password%>">
                <a href="javascript:void(0);" class="edit"><%=ssid%> <i class="icon-edit"></i></a>
            </form>
            <% else %>
            <%=ssid%>
            <% end %>
        </td>
        <td><%=wifi.signal_strength%></td>
        <td>
            <% if wifi.encryption then %>
            <% if wifi.password then %>
            <form method="POST" action="<%=connect_url%>">
                <input type="hidden" name="ssid" value="<%=ssid%>">
                <input type="hidden" name="bssid" value="<%=wifi.bssid%>">
                <input type="hidden" name="encryption" value="<%=wifi.encryption%>">
                <input type="hidden" name="password" value="<%=wifi.password%>">
                <button class="btn connect">连接</button>
            </form>
            <% else %>
            <form method="GET" action="<%=configure_url%>">
                <input type="hidden" name="ssid" value="<%=ssid%>">
                <input type="hidden" name="bssid" value="<%=wifi.bssid%>">
                <input type="hidden" name="encryption" value="<%=wifi.encryption%>">
                <button class="btn connect">连接</button>
            </form>
            <% end %>
            <% else %>
            <p>尚未支持该无线的加密方式</p>
            <% end %>
        </td>
    </tr>
    <% end %>
    </tbody>
</table>
<% else %>
<p>没有扫描到无线</p>
<% end %>
<% if #remote_saved_upstream_list > 0 then %>
<h2>不在附近的无线</h2>
<ul>
    <% for i, upstream in ipairs(remote_saved_upstream_list) do %>
    <li>
        <form method="GET" action="<%=configure_url%>">
            <input type="hidden" name="ssid" value="<%=upstream.ssid%>">
            <input type="hidden" name="bssid" value="<%=upstream.bssid%>">
            <input type="hidden" name="encryption" value="<%=upstream.encryption%>">
            <input type="hidden" name="password" value="<%=upstream.password%>">
            <a href="javascript:void(0);" class="edit"><%=upstream.ssid%> <i class="icon-edit"></i></a>
        </form>
    </li>
    <% end %>
</ul>
<% end %>
<script type="text/javascript">
    $(document).ready(function () {
        $('a.edit').click(function () {
            $(this).parents('form').submit();
        });
    });
</script>
<%+fqrouter/footer%>